package com.yan.mvc.config;

import com.yan.crowd.entity.Admin;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.List;

/**
 * 为了能够获取到原始的Admin对象,对user类进行扩展
 */
public class SecurityAdmin extends User {

    private Admin originalAdmin;

    public SecurityAdmin(Admin admin, List<GrantedAuthority> authorities) {
        super(admin.getLoginAcct(),admin.getUserPswd(),authorities);
        this.originalAdmin = admin;
        this.originalAdmin.setUserPswd(null);
    }

    public Admin getAdmin() {
        return originalAdmin;
    }

}
